<style>
table tbody tr:hover {
    background-color: #efefef;
}

.file-input {
    width: 50%;
}

.log_div {
    height: 500px;
    width: 97%;
    background-color: black;
    color: white;
    position: absolute;
    overflow-y: auto;
    margin-top: 20px;
}

div[msgType='error'] {
    color: red;
}

div[msgType='success'] {
    color: greenyellow;
    font-weight: bold;
    align-content: center;
}
div[msgType='version'] {
    color: yellow;
    font-weight: bold;
    align-content: center;
}
</style>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <span>工程名称&nbsp;&nbsp;:&nbsp;&nbsp;{{info.selectProject}}</span>
                    <a id="configInfo" href="javascript:void(0)" class="btn-link" type="button" title="工程信息" style="padding-left: 5%;" data-container="body" data-toggle="popover" data-placement="bottom" data-content="{{info.projectTip}}" data-html="true" data-trigger="focus">显示配置信息</a>

                    <span ng-if="info.planPro != null" style="padding-left: 3%;">
                        项目名称&nbsp;&nbsp;:&nbsp;&nbsp;
                        <a href="javascript:void(0);" ng-click="toPlan(info.planPro.plan_id)">{{info.planPro.plan_name}}</a>
                    </span>
                    <a href="javascript:void(0)" style="color: red;padding-left: 100px;" ng-click="openSonar();" ng-show="info.sonarUrl != ''">点击访问sonar查看检查结果</a>
                    <button class="btn btn-info" ng-click="goBack();" ng-show="showGoBack();">返回</button>
                    <br>
                    <br>
                    <table width="100%;">
                        <tr style="line-height: 40px;">
                            <td style="width: 5%;">主干工程:</td>
                            <td style="width: 20%;">
                                <input type="text" ng-model="info.trunkInfo" placeholder="选择主干工程" uib-typeahead="project as project.projectName for project in info.trunkList | filter:{projectName:$viewValue}|limitTo:15" typeahead-template-url="projectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-on-select="trunkSelect();" typeahead-select-on-blur="true">
                            </td>
                            <td style="width: 5%;text-align: center;">分支工程:</td>
                            <td style="width: 20%;">
                                <input type="text" ng-model="info.projectInfo" placeholder="选择分支工程" uib-typeahead="project as project.projectName for project in info.projectList | filter:{projectName:$viewValue}|limitTo:15" typeahead-template-url="projectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-on-select="projectSelect();" typeahead-select-on-blur="true">
                            </td>
                            <td style="width: 50%;">
                                <button style="margin-left: 20%;" class="btn btn-default pull-left" data-ng-click="doBuild();" ng-disabled="info.isRunning" ng-show="isUserCanOperateByRole('dev')">执行构建</button>
                                <img style="width: 33px;height: 33px;margin-left: 5%;" src="/beetle/image/loading.gif" ng-if="info.projectInfo.buildStatus == 'on_build' || info.projectInfo.buildStatus == 'in_queue'" />
                                <span ng-if="info.projectInfo.buildStatus == 'on_build'">构建中......</span>
                                <span ng-if="info.projectInfo.buildStatus == 'in_queue'">排队中......</span>
                            </td>
                        </tr>
                        <tr style="line-height: 40px;">
                            <td>虚拟机环境:</td>
                            <td colspan="4">
                                <span ng-repeat="uc in info.ucList track by $index" ng-if="info.ucList.length > 0" style="padding-left: 1%;">
                                    <a href="javascript:void(0);" ng-click="goToUcloudPage(uc);">{{uc.type}}</a>
                                </span>
                                <span ng-if="info.ucList.length > 0" style="padding-left: 10%;color: blue;">
                                    点击环境名称,跳转至工程对应项目的uCloud环境
                                </span>
                                <span ng-if="info.ucList.length == 0" style="color: red;">该工程项目没有虚拟机环境</span>
                            </td>
                        </tr>
                        <tr style="line-height: 25px;">
                            <td colspan="5" style="font-size: 14px;">
                                <span style="color: blue;">注:</span><br>
                                <span style="color: blue;">1.点击版本号可查看当前版本发布包在nas上的路径。提交测试后可在nas的build下得到发布包,测试通过后可在nas的WinitRelease下得到发布包.</span><br>
                                <span>2.只有<span style="color: red;">项目内工程</span>才可以点击"提交测试"、"测试通过"等流程控制按钮.</span><br>
                                <span>3.只有<span style="color: red;">临时版本</span>在<span style="color: red;">构建成功</span>后才能提交测试.</span><br>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="box-body" style="margin-top:1px;">
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="" data-ng-repeat="tab in info.tabs track by $index" ng-class="{true:'active',false:''}[$index==info.tabIndex]">
                            <a style="cursor: pointer;" ng-click="tabClick($index);" data-toggle="tab">
                                {{tab}}</a>
                        </li>
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <!--版本列表-->
                        <div class="tab-pane fade" id="tab0" ng-class="{true:'in active',false:''}[info.tabIndex == 0]">
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th width="10%" ng-if="info.planPro != null">操作</th>
                                        <th width="15%">版本名称</th>
                                        <th width="20%">状态</th>
                                        <th width="10%">svn版本号</th>
                                        <th width="45%">备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="item" data-ng-repeat="edition in info.editionList track by $index">
                                        <td ng-if="info.planPro != null" style="text-align: center;">
                                            <!--生成版本并标记提测-->
                                            <span ng-if="isUserCanOperateByRole('dev') && edition.editionNum.indexOf('-') == -1 && info.projectInfo.buildStatus == 'build_success'">
                                                <i class="glyphicon glyphicon-hand-down" data-ng-click="toTest(true,edition);" ng-if="!info.isRunning" uib-popover="生成版本并提交测试" popover-trigger="mouseenter" style="font-size: 23px;color: blue" />
                                                <i class="glyphicon glyphicon-hand-down" ng-if="info.isRunning" uib-popover="生成版本并提交测试" popover-trigger="mouseenter" style="font-size: 23px;color: grey" />
                                            </span>
                                            <!--取消提测-->
                                            <span style="padding-left: 1%;" ng-if="isUserCanOperateByRole('dev') && edition.editionNum.indexOf('-') != -1 && edition.editionNum == info.planPro.to_test_edition && edition.editionNum != info.projectInfo.testPassEdition">
                                                <i class="glyphicon glyphicon-remove" data-ng-click="toTest(false,edition);" ng-if="!info.isRunning" uib-popover="取消提测" popover-trigger="mouseenter" style="font-size: 23px" />
                                                <i class="glyphicon glyphicon-remove" ng-if="info.isRunning" uib-popover="取消提测" popover-trigger="mouseenter" style="font-size: 23px;color: grey;" />
                                            </span>
                                            <!--测试通过-->
                                            <span style="padding-left: 1%;" ng-if="isUserCanOperateByRole('qa') && edition.editionNum == info.planPro.to_test_edition && edition.editionNum != info.projectInfo.testPassEdition && (edition.editionNum != info.projectInfo.pushEdition || edition.notTestPass)">
                                                <i class="glyphicon glyphicon-thumbs-up" data-ng-click="updateTestStatusConfirm(edition,true);" ng-if="!(info.isRunning || info.pushStatus=='in_push')" uib-popover="测试通过,准备发版(注意:一个主干工程只有一个分支版本可以测试通过, 一个通过后上一个版本会自动取消通过状态)" popover-trigger="mouseenter" style="font-size: 23px;" />
                                                <i class="glyphicon glyphicon-thumbs-up" ng-if="info.isRunning || info.pushStatus=='in_push'" uib-popover="测试通过,准备发版(注意:一个主干工程只有一个分支版本可以测试通过, 一个通过后上一个版本会自动取消通过状态)" popover-trigger="mouseenter" style="font-size: 23px;color: grey;" />
                                            </span>
                                            <!--发现Bug-->
                                            <span style="padding-left: 1%;" ng-if="isUserCanOperateByRole('qa') && (edition.editionNum == info.projectInfo.testPassEdition || edition.editionNum == info.planPro.to_test_edition) && !edition.notTestPass">
                                                <i class="glyphicon glyphicon-thumbs-down" data-ng-click="updateTestStatusConfirm(edition,false);" ng-if="!info.isRunning" uib-popover="发现Bug" popover-trigger="mouseenter" style="font-size: 23px;" />
                                                <i class="glyphicon glyphicon-thumbs-down" ng-if="info.isRunning" uib-popover="发现Bug" popover-trigger="mouseenter" style="font-size: 23px;color: grey;" />
                                            </span>
                                            <!--推送失败 重新推送-->
                                            <span style="padding-left: 1%;" ng-if="isUserCanOperateByRole('qa') && edition.editionNum == info.projectInfo.pushEdition && edition.editionNum == info.planPro.to_test_edition && (info.pushStatus == 'push_error' || info.pushStatus == 'push_exception') && !edition.notTestPass">
                                                <i class="glyphicon glyphicon-repeat" data-ng-click="rePush(edition);" ng-if="!info.isRunning" uib-popover="重新推送" popover-trigger="mouseenter" style="font-size: 23px;"/>
                                                <i class="glyphicon glyphicon-repeat" ng-if="info.isRunning" uib-popover="重新推送" popover-trigger="mouseenter" style="font-size: 23px;color: grey;"/>
                                            </span>
                                        </td>
                                        <td>
                                            <span ng-if="edition.editionNum.indexOf('-') != -1">
                                                <a href="javascript:void(0)" class="btn-link" popover-title="版本nas路径" type="button" popover-trigger="outsideClick" uib-popover="{{edition.tip}}">{{edition.editionNum}}</a>
                                            </span>
                                            <span ng-if="edition.editionNum.indexOf('-') == -1">临时版本</span>
                                        </td>
                                        <td>
                                            <i class="glyphicon glyphicon-minus" ng-if="info.projectInfo.buildStatus == 'never_build' && edition.editionNum.indexOf('-') == -1">未构建过</i>
                                            <i class="glyphicon glyphicon-tasks" style="color: gray;" ng-if="info.projectInfo.buildStatus == 'on_build' && edition.editionNum.indexOf('-') == -1">构建中...</i>
                                            <i class="glyphicon glyphicon-warning-sign" ng-if="info.projectInfo.buildStatus == 'build_failed' && edition.editionNum.indexOf('-') == -1" style="color: red">构建失败</i>
                                            <i class="glyphicon glyphicon-ok" style="color: blue" ng-if="info.projectInfo.buildStatus == 'build_success' && edition.editionNum.indexOf('-') == -1">构建成功</i>
                                            <i ng-if="info.projectInfo.buildStatus == 'create_edition' && edition.editionNum.indexOf('-') == -1">已生成版本</i>
                                            <i class="glyphicon glyphicon-time" ng-if="info.projectInfo.buildStatus == 'in_queue' && edition.editionNum.indexOf('-') == -1">排队等待, 请稍后....</i>
                                            <i class="glyphicon glyphicon-hand-right" ng-if="edition.editionNum == info.projectInfo.qaTestEdition && edition.editionNum != info.projectInfo.pushEdition && !edition.notTestPass" style="color: blue">QA请测试</i>

                                            <i class="glyphicon glyphicon-thumbs-up" style="color: blue" ng-if="!edition.notTestPass && edition.editionNum == info.projectInfo.pushEdition && edition.editionNum == info.projectInfo.qaTestEdition && info.pushStatus == 'never_push'">测试通过(未推送)</i>
                                            <i class="glyphicon glyphicon-cloud-upload" style="color: gray" ng-if="!edition.notTestPass && edition.editionNum == info.projectInfo.pushEdition && edition.editionNum == info.projectInfo.qaTestEdition && info.pushStatus == 'in_push'">跳板机推送中,请稍后......</i>
                                            <i class="glyphicon glyphicon-thumbs-up" style="color: goldenrod" ng-if="!edition.notTestPass && edition.editionNum == info.projectInfo.pushEdition && edition.editionNum == info.projectInfo.qaTestEdition && info.pushStatus == 'push_success'">测试通过,等待发版</i>
                                            <i class="glyphicon glyphicon-info-sign" style="color: red" ng-if="!edition.notTestPass && edition.editionNum == info.projectInfo.pushEdition && edition.editionNum == info.projectInfo.qaTestEdition && (info.pushStatus == 'push_error' || info.pushStatus == 'push_exception')">推送出现异常,请联络管理员({{info.pushDesc}})</i>
                                            <i class="glyphicon glyphicon-thumbs-down" ng-if="edition.notTestPass" style="color: red">测试不通过</i>

                                            <i style="color: blue;" ng-if="!edition.notTestPass && info.projectInfo.buildStatus == 'build_success' && edition.editionNum.indexOf('-') == -1">({{edition.createDate}})</i>
                                        </td>
                                        <td>
                                            <span ng-if="edition.svnVersion != 0">{{edition.svnVersion}}</span>
                                        </td>
                                        <td>
                                            <input style="width: 80%;" ng-show="edition.modifiable" type="text" class="form-control" data-ng-model="edition.desc">
                                            <span ng-show="!(edition.modifiable)">{{edition.desc}}</span>
                                            <button class="btn btn-primary" style="float: right;" ng-click="editDesc('edition',edition);" type="button" ng-disabled="info.isRunning"><span class="glyphicon glyphicon-edit"></span></button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <span>最多可以保存{{info.editionCountMax}}个版本</span>
                        </div>
                        <!--SQLs-->
                        <div class="tab-pane fade" id="tab1" ng-class="{true:'in active',false:''}[info.tabIndex == 1]">
                            <div style="float: right;">
                                <i class="glyphicon glyphicon-download-alt" data-ng-click="downloadZipFile();" ng-if="!info.isRunning && info.sqls.length != 0" uib-popover="打包下载所有sql文件" popover-trigger="mouseenter" style="font-size: 23px;margin-right: 100px;"/>
                            </div>
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th width="25%">操作</th>
                                        <th width="25%">文件名</th>
                                        <th width="25%">上传日期</th>
                                        <th width="25%">备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="item" data-ng-repeat="sql in info.sqls track by $index">
                                        <td>
                                            <button class="btn btn-default pull-left" data-ng-click="delFile('sql',sql);" ng-disabled="info.isRunning">删除</button>
                                        </td>
                                        <td><a href="javascript:void(0);" ng-click="downloadFile(sql.fileName);" title="下载文件">{{sql.fileName}}</a></td>
                                        <td data-ng-bind="sql.createDate"></td>
                                        <td>
                                            <input style="width: 80%;" ng-show="sql.modifiable" type="text" class="form-control" data-ng-model="sql.desc">
                                            <span ng-show="!(sql.modifiable)">{{sql.desc}}</span>
                                            <button class="btn btn-primary" style="float: right;" ng-click="editDesc('sql',sql);" type="button" ng-disabled="info.isRunning"><span class="glyphicon glyphicon-edit"></span></button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <br>
                            <span>请选择要上传的sql文件,仅支持.sql结尾的文件</span>
                            <input id="sqlFile" type="file" multiple name="file" class="file" data-show-preview="false">
                        </div>
                        <!--Excels-->
                        <div class="tab-pane fade" id="tab2" ng-class="{true:'in active',false:''}[info.tabIndex == 2]">
                            <div style="float: right;">
                                <i class="glyphicon glyphicon-download-alt" data-ng-click="downloadZipFile();" ng-if="!info.isRunning && info.excels.length != 0" uib-popover="打包下载所有excel文件" popover-trigger="mouseenter" style="font-size: 23px;margin-right: 100px;"/>
                            </div>
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th width="25%">操作</th>
                                        <th width="25%">文件名</th>
                                        <th width="25%">上传日期</th>
                                        <th width="25%">备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr class="item" data-ng-repeat="excel in info.excels track by $index">
                                        <td>
                                            <button class="btn btn-default pull-left" data-ng-click="delFile('excel',excel);" ng-disabled="info.isRunning">删除</button>
                                        </td>
                                        <td><a href="javascript:void(0);" ng-click="downloadFile(excel.fileName);" title="下载文件">{{excel.fileName}}</a></td>
                                        <td data-ng-bind="excel.createDate"></td>
                                        <td>
                                            <input style="width: 80%;" ng-show="excel.modifiable" type="text" class="form-control" data-ng-model="excel.desc">
                                            <span ng-show="!(excel.modifiable)">{{excel.desc}}</span>
                                            <button class="btn btn-primary" style="float: right;" ng-click="editDesc('excel',excel);" type="button" ng-disabled="info.isRunning"><span class="glyphicon glyphicon-edit"></span></button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <br>
                            <span>请选择要上传的excel文件,仅支持.xls/.xlsx结尾的文件</span>
                            <input id="excelFile" type="file" multiple name="file" class="file" data-show-preview="false">
                        </div>
                        <!--构建日志-->
                        <div class="tab-pane fade" id="tab3" ng-class="{true:'in active',false:''}[info.tabIndex == 3]">
                            <div style="height: 530px;">
                                <button style="margin-top: 3px;color: red;" uib-popover="点击按钮查看完整的构建日志" popover-trigger="mouseenter" class="btn btn-default pull-left" data-ng-click="openShowLogModal('lg');">查看构建日志</button>
                                <div id="log_div" class="log_div" style="margin-top: 40px;" ng-bind-html="info.buildLog"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/ng-template" id="projectTemplate.html">
    <a>
        <span ng-bind-html="match.label | uibTypeaheadHighlight:query"></span>
    </a>
</script>
<script type="text/ng-template" id="BuildLogModal.html">
    <div class="modal-header">
        <h3 class="modal-title">构建日志<small><cite title="Source Title">{{logPath}}</cite></small></h3>
    </div>
    <div class="modal-body" style="height: 520px;">
        <div ng-bind-html="log" class="log_div"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-click="cancel()">关闭</button>
    </div>
</script>
